#include "eulerApp.h"
#include <math.h>

using namespace std;
namespace rkwolek {

    EulerApp::EulerApp(double t0, double x0, double T, double(*f)(double, double)) {
        this->tini = t0;
        this->ison = x0;
        this->tend = T;
        this->sfn = f;
    }

    double* EulerApp::function(int n) {
        double *x = new double [n + 1];
        double h = 1.0 / 100.0; //(tend-tini)/n;
        x[0] = ison;
        for (int k = 0; k < n; k++) {
            x[k + 1] = x[k] + h * sfn(tini + k * h, x[k]);
        }
        return x;
    }
}
